﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PlanningGIS.Win.Controls
{
    /// <summary>
    /// 控件检验
    /// </summary>
    public class ControlVerify
    {
        /// <summary>
        /// 只允许输入数字，符号[-]以及小数点[.]
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void txtDoubleBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8 && e.KeyChar != 46 && e.KeyChar != 45)
                e.Handled = true;
            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                e.Handled = false;

        }

        /// <summary>
        /// 只允许输入整数
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public static void txtIntBox_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
        {
            if ((e.KeyChar < 48 || e.KeyChar > 57) && e.KeyChar != 8)
                e.Handled = true;
            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
                e.Handled = false;

        }
    }
}
